package petstore.service;

import petstore.domain.Category;
import petstore.domain.Item;
import petstore.domain.Product;
import petstore.persistence.CategoryDaoImpl;
import petstore.persistence.ItemDaoImpl;
import petstore.persistence.ProductDaoImpl;
import petstore.persistence.impl.CategoryDao;
import petstore.persistence.impl.ItemDao;
import petstore.persistence.impl.ProductDao;

import javax.naming.Name;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class CatalogService extends HttpServlet
{
    private CategoryDao categoryDao;
    private ProductDao productDao;
    private ItemDao itemDao;
    public CatalogService()
    {
        this.categoryDao = new CategoryDaoImpl();
        this.productDao = new ProductDaoImpl();
        this.itemDao = new ItemDaoImpl();
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
    public List <Product> getProductListByName(String name){return productDao.searchProductList(name);}


    public List<Category> getCategoryList()
    {
        return categoryDao.getCategoryList();
    }

    public Category getCategory(String categoryId)
    {
        return categoryDao.getCategory(categoryId);
    }

    public List<Product> getProductListBycategoryId(String categoryId)
    {
        return productDao.getProductListByCategoryId(categoryId);
    }

    public Product getProduct(String productId)
    {
        return productDao.getProduct(productId);
    }

    public List<Product> searchProductList(String keyword)
    {
        return null;
    }

    public List<Item> getItemListByProduct(String productId)
    {
        return itemDao.getItemListByProductId(productId);
    }

    public Item getItem(String itemId)
    {
        return itemDao.getItem(itemId);
    }

}
